package com.yycx.module.bus.provider.handler;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.base.handler.UserDeptAssignHandler;
import com.yycx.common.constants.CommonConstants;
import com.yycx.common.mybatis.query.CriteriaQuery;
import com.yycx.common.security.OpenHelper;
import com.yycx.module.bus.client.entity.BusDept;
import com.yycx.module.bus.provider.service.BusDeptService;
import com.yycx.module.system.client.entity.SysCompany;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class GetDeptAssignHandler implements UserDeptAssignHandler {
    @Autowired
    private BusDeptService deptService;


    @Override
    public EntityMap getAuthDeptList(Long userId, Long organizationId) {
        CriteriaQuery cq = new CriteriaQuery(BusDept.class);
        cq.select(BusDept.class, "deptId", "deptName");
        cq.eq(BusDept.class, "deptState", 1);
        cq.orderByAsc("deptName");
        cq.eq(BusDept.class, "companyId", OpenHelper.getCompanyId());
        List<EntityMap> list = deptService.selectEntityMap(cq);
        EntityMap map = new EntityMap();
        map.put("deptList", list);
        return map;
    }
}
